
#include "atomic_op_asm.h"

ENTRY_NP(_atomic_inc_32)
1:	ldxr	w3, [x0]		/* load old value (return value) */
	add	w3, w3, #1		/* calculate new value */
	stxr	w2, w3, [x0]		/* try to store */
	cbnz	w2, 1b			/*   succeed? no, try again? */
	dmb	st
	ret				/* return new value */
END(_atomic_inc_32)

ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32)

ENTRY_NP(_atomic_inc_32_nv)
	mov	x4, x0			/* need r0 for return value */
1:	ldxr	w0, [x4]		/* load old value */
	add	w0, w0, #1		/* calculate new value (return value) */
	stxr	w3, w0, [x4]		/* try to store */
	cbnz	w3, 1b			/*   succeed? no, try again? */
	dmb	st
	ret				/* return new value */
END(_atomic_inc_32_nv)

ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
